Original Post
I have an existing engine thats working out quite well. I''m usng ODE for physics and as such didn''t really need to learn too much about matricies.
Now I want to add GOD mode to the engine, mostly as a prelude to creating an editor. I''ve implemented this as well but my mouse control of camera''s orientation is slightly wrong.
Where is what I do:
-Get User input from mouse.
-Calculate Mouse Delta.
-Apply the mouse delta to the camera''s orientation like this:
Transform.SetYaw(m_Delta.x);
Transform.SetPitch(m_Delta.y);
-Go on with normal rendering.
Here is an example of my SetPitch:
(I stole this from Nate Millers code more or less)
The odd thing that I''m getting is that when I wiggle the mouse around(say move the camera in a small circular motion) the camera slowly rolls clockwise and even though I never touch the roll it rolls anyway. Is there an error in my ocde or is this inherent in what I''m doing. If it''s inherent is there any way to lock the roll os ''up'' is always ''up''?
Many thanks,
Chris Brodie
http:\\fourth.flipcode.com
void CMatrix::SetPitch(const float a_Degrees)
{
CMatrix temp(CMatrix::IDENTITY);
float Radians = Mathematics::Degrees2Radians(a_Degrees);
float c = (float)cos(Radians);
float s = (float)sin(Radians);
temp.m[5] = c;
temp.m[6] = s;
temp.m[9] = -s;
temp.m[10] = c;
*this = temp * *this;
}
void CMatrix::SetYaw(const float a_Degrees)
{
CMatrix temp(CMatrix::IDENTITY);
float Radians = Mathematics::Degrees2Radians(a_Degrees);
float c = (float)cos(Radians);
float s = (float)sin(Radians);
temp.m[0] = c;
temp.m[2] = -s;
temp.m[8] = s;
temp.m[10] = c;
*this = temp * *this;
}